package annotation;

import java.lang.annotation.*;
import java.lang.reflect.Field;

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD,ElementType.FIELD,ElementType.TYPE})
@interface Entry{
    String value() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
@interface ID{
    String value() default "";
}


@Entry("t_user")
class  User{
    @ID("uid")
    private Integer id;
}


public class AnnotationTests {

    public static void main(String[] args) {

            try {
                Class clz = Class.forName("annotation.User");
                Entry entry = (Entry) clz.getAnnotation(Entry.class);
                String name = entry.value();
                System.out.println(name);
                Field field = clz.getDeclaredField("id");
                ID id =  field.getAnnotation(ID.class);
          //      id.value();
                System.out.println(id.value());
            } catch (ClassNotFoundException | NoSuchFieldException e) {
                e.printStackTrace();
            }

    }




}
